package com.xhtt.modules.cfg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhtt.modules.cfg.dao.CfgStandMapper;
import com.xhtt.modules.cfg.entity.CfgStand;
import com.xhtt.modules.cfg.service.CfgProductService;
import com.xhtt.modules.cfg.service.CfgStandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author feipc
 * @since 2019-02-18
 */
@Service
public class CfgStandServiceImpl extends ServiceImpl<CfgStandMapper, CfgStand> implements CfgStandService {
    @Autowired
    private CfgProductService cfgProductService;

    @Override
    public List<CfgStand> standList(Map<String, Object> params) {
        Object name = params.get("name");
        Object islandId = params.get("islandId");
        List<CfgStand> list = this.list(new LambdaQueryWrapper<CfgStand>().eq(CfgStand::getStatus, 1).like(!ObjectUtils.isEmpty(name), CfgStand::getName, name).eq(!ObjectUtils.isEmpty(islandId), CfgStand::getIslandId, islandId));
        return list;
    }

    @Override
    public void deleteStand(Integer id) {
        CfgStand stand = this.getById(id);
        stand.setStatus(-1);
        this.updateById(stand);
    }
}
